<?  
	$title="Upload Display Picture"; 
	$pageid="2";
	$accessid="a00";

	require("required/dbconnect.php"); 
	require("required/function.php");

	require("required/header.php");
	
	
	$errormsg="";
	$description=$_POST['description'];
	
	
	
	$allowed_ext = "jpg, gif, jpeg, JPEG, JPG, GIF"; 
	$max_size = "9000000"; 
	$ok="";
	
	if(is_uploaded_file($_FILES['file']['tmp_name'])==true)
	{
		$extension = pathinfo($_FILES['file']['name']);
		$extension = $extension['extension'];
		
		if($_FILES['file']['size'] > $max_size)
		{
			$errormsg="file size too big, must smaller than 2MB";
			$back="<input type=button value=\"Back\" onclick=\"history.go(-1)\" class=button>";
		}
		else
		{
			if(is_uploaded_file($_FILES['file']['tmp_name']))
			{
				
				
				
				
				$insert_q="insert into os_uploadfiles(description,filename,type,file_extention,file_size)values('$description','".$_FILES["file"]["name"]."','collection','$extension',".$_FILES['file']['size'].")";
				$insert_r=mysql_query($insert_q)or die(mysql_error());
				
				$uploadedfile = $_FILES['file']['tmp_name'];
				move_uploaded_file($_FILES["file"]["tmp_name"],"../uploadfiles/".$_FILES["file"]["name"]);
			}
			$errormsg="File successfully uploaded!";
			$success="1";
			$back="<input type=button value=\"Back\" onclick=\"window.open('collection_file_upload.php','_self')\" class=button>";
		}
	}
	else
	{
		$errormsg="You didn't choose a picture to upload or the picture size is too big";
		$back="<input type=button value=\"Back\" onclick=\"history.go(-1)\" class=button>";
	}

	
	
?>
<table>
		
  <tr>
    <td class="title">Upload Files</td>
  </tr>
  <tr>
	<td align="center"><br><br>
	<font color=red><?= $errormsg ?></font><br><br>
	<?= $back ?><br><br>
	</td>
 </tr>
 
</table>
<? require("required/footer.php"); ?>
      
  